﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zeus.Thunder.Core;

namespace SharpTrainer.Delegates
{
    class DelegateCombine2 : ITestCase
    {
        public void Run()
        {
            Func<int, int, int> add = 
                (a, b) => { 
                    Console.Write("+ : "); 
                    return a + b; 
                };

            Func<int, int, int> mul = 
                (a, b) => { 
                    Console.Write("* : "); 
                    return a * b; 
                };

            Func<int, int, int> all = add + mul;
            Console.WriteLine(add(2, 3));
            Console.WriteLine(mul(2, 3));
            Console.WriteLine(all(2, 3));

            Console.WriteLine("Using List:");

            var allList = new List<Func<int, int, int>> { add, mul };
            foreach (var op in allList)
                Console.WriteLine(op(3,3));
        }
    }
}
